package com.example.sunflowers.data.db

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import java.util.Calendar

/**
 *
 * @Author： LJH
 * @Time： 2024/1/26
 * @description：
 */
@Entity(tableName = "plants")
data class Plant(
    @PrimaryKey
    @ColumnInfo(name = "id")
    val plantId:String,
    val name:String,
    val description:String,
    val growZoneNumber:Int,
    val waterInterval:Int = 7, // how often the plant should be watered, in days
    val imageUrl:String = ""
) {
    fun shouldBeWatered(since:Calendar,lastWateringDate:Calendar) =
        since > lastWateringDate.apply { add(Calendar.DAY_OF_YEAR,waterInterval) }

    override fun toString() = name
}